-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Breaking Change][lexical-list] Fix: Preserve original format after indenting list item #6912
[Breaking Change][lexical-list] Fix: Preserve original format after indenting list item #6912
Conversation
…com/citruscai/lexical into fix/listitem-format-indentation-bug
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
size-limit report 📦
|
…itruscai/lexical into fix/list-indention-format-loss
…iting from paragraphnode
const listItemNode = $getNearestNodeOfType(node, ListItemNode); | ||
if ($isListItemNode(node)) { | ||
const listItemNode = $getNearestNodeOfType(node, ListItemNode); | ||
|
||
if (listItemNode != null) { | ||
listNodes.add($getTopListNode(listItemNode)); | ||
if (listItemNode != null) { | ||
listNodes.add($getTopListNode(listItemNode)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this change is wrong. $isLeafNode(node)
and $isListItemNode(node)
are never true at the same time, so this block never does anything now. I guess there just isn't test coverage for what it's trying to do. Can you put this block back to the way it was and see if the tests still pass?
I'm currently trying to get a clean test run, please don't do any updates unless you have a reason to change the code manually (clicking the update button will run all of the tests again which is slowing this review down) |
no problem, sorry about that! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done!
There's currently an issue with the merge queue settings that I don't have permissions to fix, but it will be merged when that is resolved. Please don't make any updates in the meantime. |
This change was reverted in #6944 due to some compatibility issues internally at Meta with the change in class hierarchy. The majority of this change is good, but in order to have better backwards compatibility the most pragmatic approach will be to create a new base class common to ParagraphNode and ListItemNode that has the common functionality so that |
Description
This PR fixes the issue of format from previous list item being lost when you indent the new list item.
Changes
Upgrade Notes
The base class for ListItemNode has changed from ElementNode to ParagraphNode which may cause issues in limited situations if you have subclassed ListItemNode:
There may also be issues with type narrowing if you have code that checks
$isParagraphNode(node)
and expects this to be disjoint from$isListItemNode(node)
, e.g. this is now wrong:But it can be fixed by re-ordering the conditions:
Closes #6476
Before
listindentbug.mp4
After
listindentfix.mp4